﻿package net.molchat.android.scrn;


import java.util.ArrayList;
import java.util.List;

import net.molchat.android.mess.Message;

import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Region;
import android.util.Log;
import android.view.KeyEvent;


//FIXME Commented out old class


//import javax.microedition.lcdui.Command;
//import javax.microedition.lcdui.Graphics;
//
//import net.molchat.android.core.*;
//import net.molchat.android.mess.*;


//================================================================ Splash screen
public final class Splash implements Win {


//======================================================================= Fields
private Paint p;

private int textX, textY; // Next text label coordinates
private List<String> texts = new ArrayList<String>();


private int percent;


//================================================================== Constructor
public Splash() {

	Log.v("Splash", "=====");

	p = new Paint();
	p.setARGB(0xff, 0, 0, 0);
	p.setStrokeWidth(0);
}


public boolean isGraphic() {

	return true;
}


/**
 * See @link Win.prepare.
 */
@Override
public void prepare(Win winOld) {

	drawFrame();
	drawTexts();
}


private void drawTexts() {

	p.setAntiAlias(true);
	textX = Draw.fact5 << 1;
	textY = (Draw.fact5 << 1) + Draw.fontMessH;

	synchronized (texts) {
		for (String text : texts) {
			Draw.g.drawText(text, textX, textY, p);
			textY += Draw.fontMessH;
		}
	}
}


//========================================================================= tick
@Override
public boolean tick() {

	return false;
}


//========================================================= First starting frame
private void drawFrame() {

	Draw.g.clipRect(0, 0, Draw.dispW, Draw.dispH, Region.Op.REPLACE);
	p.setAntiAlias(false);
	Draw.g.drawColor(Color.rgb(0xff, 0xff, 0xff));
	Draw.g.drawLine(Draw.fact5, Draw.fact5, Draw.dispW - Draw.fact5, Draw.fact5,
			p);
	Draw.g.drawLine(Draw.dispW - Draw.fact5, Draw.fact5, Draw.dispW - Draw.fact5,
			Draw.dispH - Draw.fact5, p);
	Draw.g.drawLine(Draw.dispW - Draw.fact5, Draw.dispH - Draw.fact5, Draw.fact5,
			Draw.dispH - Draw.fact5, p);
	Draw.g.drawLine(Draw.fact5, Draw.dispH - Draw.fact5, Draw.fact5, Draw.fact5,
			p);
}


//============================================================== Следующий текст
public void next(String text, int percent) {

	this.percent = percent;
	synchronized (texts) {
		this.texts.add(text);
	}
}


//======================================================================= chStat
public boolean chStat(String statText) {

	this.next(statText, this.percent);
	return true;
}


//
//// Команды
//public boolean[] coms = new boolean[ScrMan.COM_TOT];
//{
//	coms[ScrMan.COM_SETTINGS] = true;
//	coms[ScrMan.COM_EXIT] = true;
//}
//
//
////============================================================= Изменился статус
//public boolean chStat(String statText) {
//
//	return false;
//}
//
//
//// =========================================== Освободить ресурсы и закрыть окно
//public void close(int from) {
//
//	if (from <= Mess.LOCAL) {
//		//
//	}
//}
//
//
////===================================================== Изменился режим "В сети"
//public void fOnline(boolean fOnline) {
//
//}
//
//
//// ===================================================== Вернуть перечень команд
//public boolean[] getComs() {
//
//	return coms;
//}


//======================================================================== Выход
public void exit(int from) {

}


// ============================================= Извещение о пришедшем сообщении
@Override
public boolean inText(int contType, int contNum, Message message) {

	return false;
}


@Override
public boolean keyDown(int keyCode, KeyEvent event) {

	// TODO Auto-generated method stub
	return false;
}


//public boolean keyState(int keyState) {
//
//	return false;
//}
//
//
//public void command(Command command) {
//
//	// TODO Auto-generated method stub
//
//}


public void pointerDragged(int offX, int offY) {

	// TODO Auto-generated method stub
}


public void pointerPressed(int x, int y) {

	// TODO Auto-generated method stub
}


public void pointerReleased(int x, int y) {

	// TODO Auto-generated method stub
}

}
